<script setup lang="ts">
import { useFeedbackController } from '@/utils/feedback-util'
import type { UploadOperatorPackageResponse } from '@/api/operator-package-api'

const props = defineProps({
  modelValue: {
    type: Boolean,
    required: true
  },
  result: {
    type: Object as () => UploadOperatorPackageResponse,
    required: true
  }
})
const emits = defineEmits(['update:modelValue'])

//<--对话框打开关闭控制
const { isShow } = useFeedbackController(props, emits)
//对话框打开关闭控制-->
</script>

<template>
  <el-dialog
    class="function-package-upload-result"
    v-model="isShow"
    :show-close="true"
    top="10vh"
  >
    <template #header> 上传结果</template>
    <el-descriptions :border="true" column="1">
      <template v-if="result.message">
        <el-descriptions-item v-for="item in result.message" :key="item[0]" :label="item[0]">
          {{ item[1] }}
        </el-descriptions-item>
      </template>
      <template v-else>
        <el-descriptions-item label="名称">
          {{ result.info?.name }}
        </el-descriptions-item>
        <el-descriptions-item label="标签">
          {{ result.info?.tag }}
        </el-descriptions-item>
        <el-descriptions-item label="算子数量">
          {{ result.info?.operatorNumber }}
        </el-descriptions-item>
        <el-descriptions-item label="文件MD5">
          {{ result.info?.md5 }}
        </el-descriptions-item>
      </template>
    </el-descriptions>
  </el-dialog>
</template>

<style scoped lang="scss">
.function-package-upload-result {
}
</style>

<style lang="scss">
.function-package-upload-result {
  .el-dialog__header {
    margin-right: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--el-border-color);
  }

  .el-dialog__body {
    padding: 20px 20px ;
  }
}
</style>
